﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage/MasterPage.master" AutoEventWireup="true"
    CodeFile="UserAdd.aspx.cs" Inherits="UserManage_UserAdd" Title="添加用户信息" Culture="auto"
    meta:resourcekey="PageResource3" UICulture="auto" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <script language="javascript" type="text/javascript">       
        function SearchCountry(ObjID)
        {
            var oid = ObjID.substring(0,ObjID.lastIndexOf('_') + 1);
            var objSearch = document.getElementById(ObjID);
            var obj1 = document.getElementById(oid + "ddlSClient"); 
            var obj = document.getElementById(oid + "ddlSClientSearch");
            
            for(var i = obj1.length-1;i > -1;i--)
            {
	            obj1.remove(i);
            }

            for(var i=0;i < obj.length;i++)
            { 
	            if(obj[i].text.toUpperCase().indexOf(objSearch.value.toUpperCase()) > -1){	            
		            obj1.add(new Option(obj[i].text,obj[i].value));	
	            }
            }            
        }    
        
        function BConfim()
        {
        var a = document.getElementsByTagName("input");
        var isSel = 0;
        for(var i=0;i<a.length;i++)
        {
            if(a[i].type == "radio")
            {
                if(a[i].checked == true)
                {
                    isSel += 1;
                }
            }
        }
        if(isSel == 0)
        {
            alert("请选择一条记录!");
            return false;
            
        }
        else
        {
           return true;
        }
      
    }    
    </script>

    <div id="myDiv" runat="server" class="divBgCover">
    </div>
    <div id="divError" runat="server" class="blue divActiveWindow">
        <%--  <div class="title">
            <asp:Label ID="lblTitle" runat="server" Text="请选择用户所属公司"></asp:Label></div>--%>
        <table width="100%" align="center">
            <tr>
                <td>
                    <asp:ScriptManager ID="ScriptManager1" runat="server">
                    </asp:ScriptManager>
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <div class="title">
                                <asp:Label ID="Label2" runat="server" Text="客户信息列表" meta:resourcekey="Label2Resource1"></asp:Label></div>
                            <table class="add_table" cellspacing="1" cellpadding="3">
                                <tr>
                                    <td align="right">
                                        <asp:DropDownList ID="ddlColumnName" runat="server" meta:resourcekey="ddlColumnNameResource1">
                                            <asp:ListItem Text="公司简称" Value="CNShortName" meta:resourcekey="ListItemResource1"></asp:ListItem>
                                            <asp:ListItem Text="公司名" Value="CNName" meta:resourcekey="ListItemResource4"></asp:ListItem>
                                            <asp:ListItem Text="电子信箱" Value="Email" meta:resourcekey="ListItemResource10"></asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtName" runat="server" meta:resourcekey="txtNameResource1"></asp:TextBox>
                                    </td>
                                    <td align="right">
                                        <asp:Label ID="lblModel" runat="server" Text="客户类型：" meta:resourcekey="lblModelResource1"></asp:Label>
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlType" runat="server" meta:resourcekey="ddlTypeResource1"
                                            Width="100px">
                                        </asp:DropDownList>
                                        <cc1:ListSearchExtender ID="ListSearchExtender2" runat="server" TargetControlID="ddlType"
                                            PromptCssClass="ListSearchExtenderPrompt">
                                        </cc1:ListSearchExtender>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="4" align="center">
                                        <asp:Button ID="btnSearch" runat="server" CssClass="btn" Text="搜索" OnClick="btnSearch_Click"
                                            meta:resourcekey="btnSearchResource1" />
                                    </td>
                                </tr>
                            </table>
                            <div id="divEntrust" runat="server">
                                <div class="list_title">
                                    <div class="autoleft">
                                        <asp:Label ID="lblSelectOut" runat="server" Text="检索出" meta:resourcekey="lblSelectOutResource1"></asp:Label>
                                        <asp:Label ID="lblTotal" runat="server" meta:resourcekey="lblTotalResource1"></asp:Label>
                                        <asp:Label ID="lblSelectOut2" runat="server" Text="个客户" meta:resourcekey="lblSelectOut2Resource1"></asp:Label></div>
                                    <div class="autoright">
                                        <asp:Label ID="lblPerPage" runat="server" Text="每页显示：" meta:resourcekey="lblPerPageResource1"></asp:Label>
                                        <asp:DropDownList ID="ddlPages" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlPages_SelectedIndexChanged"
                                            meta:resourcekey="ddlPagesResource1">
                                            <asp:ListItem Selected="True" Text="10" Value="10" meta:resourcekey="ListItemResource6"></asp:ListItem>
                                            <asp:ListItem Text="15" Value="15" meta:resourcekey="ListItemResource7"></asp:ListItem>
                                        </asp:DropDownList>
                                    </div>
                                </div>
                                <asp:GridView ID="gvClientList" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                    Width="100%" AllowSorting="True" OnPageIndexChanging="gvClientList_PageIndexChanging"
                                    OnSorting="gvClientList_Sorting"  OnRowDataBound="gvClientList_RowDataBound" meta:resourcekey="gvClientListResource1">
                                    <PagerTemplate>
                                        <table style="width: 100%">
                                            <tr>
                                                <td>
                                                    <asp:Label ID="lblPerPage" runat="server" Text="页次" meta:resourcekey="lblPerPageResource2"></asp:Label>:&nbsp;<asp:Label
                                                        ID="Label1" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex+1 %>'
                                                        meta:resourcekey="Label1Resource1"></asp:Label>/<asp:Label ID="Label2" runat="server"
                                                            Text='<%# ((GridView)Container.Parent.Parent).PageCount %>' meta:resourcekey="Label2Resource2"></asp:Label><asp:Label
                                                                ID="lblPage" runat="server" Text="页" meta:resourcekey="lblPageResource1"></asp:Label>&nbsp;
                                                    <asp:Label ID="lblTotalPages" runat="server" Text="总计" meta:resourcekey="lblTotalPagesResource1"></asp:Label>:&nbsp;<asp:Label
                                                        ID="Label3" runat="server" Text="<%# ((System.Data.DataView)gvClientList.DataSource).Count %>"
                                                        meta:resourcekey="Label3Resource1"></asp:Label>
                                                </td>
                                                <td align="right">
                                                    <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Page" CommandArgument="First"
                                                        Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=0 %>" Text="首页" meta:resourcekey="LinkButton1Resource1"></asp:LinkButton>
                                                    <asp:LinkButton ID="LinkButton2" runat="server" CommandArgument="Prev" CommandName="Page"
                                                        Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=0 %>" Text="前页" meta:resourcekey="LinkButton2Resource1"></asp:LinkButton>
                                                    <asp:LinkButton ID="LinkButton3" runat="server" CommandName="Page" CommandArgument="Next"
                                                        Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=((GridView)Container.Parent.Parent).PageCount-1 %>"
                                                        Text="后页" meta:resourcekey="LinkButton3Resource1"></asp:LinkButton>
                                                    <asp:LinkButton ID="LinkButton4" runat="server" CommandArgument="Last" CommandName="Page"
                                                        Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=((GridView)Container.Parent.Parent).PageCount-1 %>"
                                                        Text="尾页" meta:resourcekey="LinkButton4Resource1"></asp:LinkButton>&nbsp;
                                                    <asp:Label ID="lblTurnOn" runat="server" Text="转第" meta:resourcekey="lblTurnOnResource1"></asp:Label>
                                                    <asp:TextBox ID="txtPages" runat="server" Width="35px" meta:resourcekey="txtPagesResource1"></asp:TextBox>
                                                    <asp:Label ID="lblPages2" runat="server" Text="页" meta:resourcekey="lblPages2Resource1"></asp:Label>
                                                    <asp:LinkButton ID="lbtnGo" runat="server" Text="提交" OnClick="lbtnGo_Click" meta:resourcekey="lbtnGoResource1"></asp:LinkButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </PagerTemplate>
                                    <Columns>
                                        <asp:TemplateField HeaderText="选择" meta:resourcekey="TemplateFieldResource1">
                                            <ItemTemplate>
                                                <input type="radio" name="chkSelected" value='<%# DataBinder.Eval(Container.DataItem,"PKID") %>' />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="序号" meta:resourcekey="TemplateFieldResourceRowNum1">
                                            <ItemTemplate>
                                                <asp:Label ID="lblRowNum" runat="server" Text='<%#(Container as GridViewRow).RowIndex + 1%>'></asp:Label>
                                            </ItemTemplate>
                                            <ItemStyle Width="5%" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="公司简称" SortExpression="ENGName" meta:resourcekey="TemplateFieldResource2">
                                            <ItemTemplate>
                                                <asp:Label ID="lblCNName" runat="server" Text='<%# Eval("CNShortName") %>' meta:resourcekey="lblCNNameResource1"></asp:Label>
                                                <asp:Label ID="lblENName" runat="server" Text='<%# Eval("ENGShortName") %>' meta:resourcekey="lblENNameResource1"></asp:Label>
                                                <asp:Label ID="lblHKName" runat="server" Text='<%# Eval("HKShortName") %>' meta:resourcekey="lblHKNameResource1"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="电子信箱" SortExpression="Email" meta:resourcekey="TemplateFieldResourceEmail">
                                            <ItemTemplate>
                                                <asp:Label ID="lblEmail" runat="server" Text='<%# Eval("Email") %>' meta:resourcekey="lblEmailResource1"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="业务员" SortExpression="LocalBP" meta:resourcekey="TemplateFieldResource5">
                                            <ItemTemplate>
                                                <asp:Label ID="lblType" runat="server" Text='<%# Eval("LocalBP") %>' meta:resourcekey="lblTypeResource1"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <PagerSettings Mode="NumericFirstLast" />
                                    <RowStyle HorizontalAlign="Center" />
                                </asp:GridView>
                            </div>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr>
                <td align="center">
                    <asp:Button ID="btnSub" runat="server" Text="提交" CssClass="btn" OnClick="btnSub_Click"
                        meta:resourcekey="btnSubResource1" />&nbsp;&nbsp;<asp:Button ID="btnClose" CssClass="btn"
                            runat="server" Text="返回" OnClick="btnClose_Click" meta:resourcekey="btnCloseResource1" />
                    <asp:HiddenField ID="hidAdminID" runat="server" />
                </td>
            </tr>
            <tr>
                <td align="center">
                    <asp:Label ID="lblError" runat="server" Visible="False" Text="请选择一个客户!" ForeColor="Red"
                        meta:resourcekey="lblErrorResource1"></asp:Label>
                </td>
            </tr>
        </table>
    </div>
    <div class="title">
        &nbsp;<asp:Label ID="lblPageType" runat="server" Text="添加用户" meta:resourcekey="lblPageTypeResource1"></asp:Label></div>
    <table class="add_table" cellspacing="1" cellpadding="3" align="center">
        <tr>
            <td align="right">
                <asp:Label ID="Label1" runat="server" Text="所属公司：" meta:resourcekey="Label1Resource2"></asp:Label>
            </td>
            <td>
                <asp:HiddenField ID="hidClientID" runat="server" />
                <asp:TextBox ID="txtClientName" runat="server" Width="172px" Enabled="False" meta:resourcekey="txtClientNameResource1"></asp:TextBox>
                <asp:LinkButton ID="lbtnClientSel" runat="server" Text="选择..." OnClick="lbtnClientSel_Click"
                    meta:resourcekey="lbtnClientSelResource1"></asp:LinkButton>&nbsp;&nbsp;&nbsp;<asp:Label
                        ID="lblZhuYi" runat="server" ForeColor="Red" Font-Size="Small" Text="当所属公司为空时默认添加本公司用户."
                        meta:resourcekey="lblZhuYiResource1"></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="right">
                <label for="username">
                    <b style="color: Red">*</b></label><asp:Label ID="lblRoleName" runat="server" Text="登录名："
                        meta:resourcekey="lblRoleNameResource1"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtLoginID" runat="server" Width="172px" MaxLength="50" ValidationGroup="user"
                    meta:resourcekey="txtLoginIDResource1"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rqvalRoleName" runat="server" ControlToValidate="txtLoginID"
                    ErrorMessage="名称不能为空" ValidationGroup="role" meta:resourcekey="rqvalRoleNameResource1"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="right">
                <label for="password">
                    <b style="color: Red">*</b></label><asp:Label ID="lblPassword" runat="server" Text="密码："
                        meta:resourcekey="lblPasswordResource1"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtPassword" TextMode="Password" runat="server" Width="172px" ValidationGroup="user"
                    meta:resourcekey="txtPasswordResource1"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtPassword"
                    ErrorMessage="*" ValidationGroup="user" meta:resourcekey="RequiredFieldValidator1Resource1"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="right">
                <label for="confimpassword">
                    <b style="color: Red">*</b></label><asp:Label ID="lblConfimPassword" runat="server"
                        Text="确认密码：" meta:resourcekey="lblConfimPasswordResource1"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtConfimPassword" TextMode="Password" runat="server" Width="172px"
                    ValidationGroup="user" meta:resourcekey="txtConfimPasswordResource1"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtConfimPassword"
                    ErrorMessage="*" ValidationGroup="user" meta:resourcekey="RequiredFieldValidator2Resource1"></asp:RequiredFieldValidator>
                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtPassword"
                    ControlToValidate="txtConfimPassword" ErrorMessage="输入新密码不一致,请重新输入!" ValidationGroup="user"
                    meta:resourcekey="CompareValidator1Resource1"></asp:CompareValidator>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="lblRoleCode" runat="server" Text="用户名称：" meta:resourcekey="lblRoleCodeResource1"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtUserName" runat="server" Width="172px" meta:resourcekey="txtUserNameResource1"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="lblEmail" runat="server" Text="E-mail：" meta:resourcekey="lblEmailResource1"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtEmail" runat="server" Width="172px" meta:resourcekey="txtEmailResource1"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="lblUserRole" runat="server" Text="用户所属角色：" meta:resourcekey="lblUserRoleResource1"></asp:Label>
            </td>
            <td>
                <asp:CheckBoxList ID="chkRolesList" runat="server" RepeatColumns="5" RepeatDirection="Horizontal"
                    ValidationGroup="user" meta:resourcekey="chkRolesListResource1">
                </asp:CheckBoxList>
            </td>
        </tr>
        <tr>
            <td align="right">
                <asp:Label ID="lblUserStatus" runat="server" Text="状态：" meta:resourcekey="lblUserStatusResource1"></asp:Label>
            </td>
            <td>
                <asp:RadioButton ID="radYes" runat="server" Checked="True" Text="有效" GroupName="Activity"
                    meta:resourcekey="radYesResource1" /><asp:RadioButton ID="radNo" runat="server" Text="失效"
                        GroupName="Activity" meta:resourcekey="radNoResource1" />
            </td>
        </tr>
    </table>
    <table class="add_table" cellspacing="1" cellpadding="3">
        <tr>
            <td align="center">
                <asp:Button ID="btnSave" runat="server" Text="保存" OnClick="btnSave_Click" CssClass="btn"
                    ValidationGroup="user" meta:resourcekey="btnSaveResource1" />
                &nbsp;
                <asp:Button ID="btnReset" runat="server" Text="返回" CssClass="btn" OnClick="btnReset_Click"
                    meta:resourcekey="btnResetResource1" />
            </td>
        </tr>
    </table>
</asp:Content>
